<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>




<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>欢迎使用 IMOOC Cake 后台管理系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/assets/css/theme.css">
    <link rel="stylesheet" type="text/css" href="/assets/css/admin-forms.css">
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
</head>

<body class="admin-validation-page" data-spy="scroll" data-target="#nav-spy" data-offset="200">
<div id="main">
    <header class="navbar navbar-fixed-top navbar-shadow">
        <div class="navbar-branding">
            <a class="navbar-brand" href="/index.html">
                <H3>Love Cake 后台管理系统</H3>
            </a>
            <span id="toggle_sidemenu_l" class="ad ad-lines"></span>
        </div>
    </header>
    <aside id="sidebar_left" class="nano nano-light affix">
        <div class="sidebar-left-content nano-content">
            <header class="sidebar-header">
                <div class="sidebar-widget author-widget">
                    <div class="media">
                        <a class="media-left" href="#">
                            <img src="/assets/images/head.jpg" class="img-responsive">
                        </a>
                        <div class="media-body">
                            <div class="media-author">管理员</div>
                            <div class="media-links">
                                <a href="/view/login">退出</a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="sidebar-widget search-widget hidden">
                    <div class="input-group">
                        <span class="input-group-addon">
                        <i class="fa fa-search"></i>
                        </span>
                        <input type="text" id="sidebar-search" class="form-control" placeholder="Search...">
                    </div>
                </div>
            </header>
            <ul class="nav sidebar-menu">
                <li class="sidebar-label pt20">商品管理</li>
                <li class="active">
                    <a href="/view/cake_list">
                        <span class="glyphicon glyphicon-book"></span>
                        <span class="sidebar-title">商品列表</span>
                    </a>
                </li>
                <li>
                    <a href="/view/cake_add">
                        <span class="glyphicon glyphicon-home"></span>
                        <span class="sidebar-title">商品上架</span>
                    </a>
                </li>
                <li class="sidebar-label pt20">分类管理</li>
                <li class="active">
                    <a href="/view/catalog_list" oncick="getPageData()">
                        <span class="glyphicon glyphicon-book"></span>
                        <span class="sidebar-title">分类列表</span>
                    </a>
                </li>
                <li>
                    <a href="/view/catalog_add">
                        <span class="glyphicon glyphicon-home"></span>
                        <span class="sidebar-title">添加分类</span>
                    </a>
                </li>
            </ul>
            <div class="sidebar-toggle-mini">
                <a href="/view/login">
                    <span class="fa fa-sign-out"></span>
                </a>
            </div>
        </div>
    </aside>
    <section id="content_wrapper">
        <section id="content" class="table-layout animated fadeIn">
            <div class="tray tray-center">
                <div class="content-header">
                    <h2> 蛋糕管理</h2>
                    <p class="lead"></p>
                </div>
                <div class="admin-form theme-primary mw1000 center-block" style="padding-bottom: 175px;">
                    <div class="panel  heading-border">
                        <div class="panel-menu">
                            <div class="row">
                                <div class="hidden-xs hidden-sm col-md-3">
                                    <div class="btn-group">
                                        <button type="button" class="btn btn-default light">
                                            <i class="fa fa-trash"></i>
                                        </button>
                                        <button type="button" class="btn btn-default light">
                                            <i class="fa fa-plus" onclick="javascript:window.location.href='/view/cake_add';"></i>
                                        </button>
                                    </div>
                                </div>
                                <div class="col-xs-12 col-md-9 text-right">
                                    <form action="cake_list.html" method="post">
                                        共35条 1/2
                                        <div class="btn-group">
                                            <button type="submit" name="pageNum" value="0" class="btn btn-default light">
                                                <i class="fa fa-chevron-left"></i>
                                            </button>
                                            <button type="submit" name="pageNum" value="2" class="btn btn-default light">
                                                <i class="fa fa-chevron-right"></i>
                                            </button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="panel-body pn">
                            <table id="message-table" class="table admin-form theme-warning tc-checkbox-1">
                                <thead>
                                <tr class="">
                                    <th class="text-center hidden-xs">Select</th>
                                    <th class="hidden-xs">名称</th>
                                    <th class="hidden-xs">类型</th>
                                    <th class="hidden-xs">价格</th>
                                    <th class="hidden-xs">口味</th>
                                    <th class="hidden-xs">尺寸</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody id="type">

<%--                                <tr class="message-unread">--%>
<%--                                    <td class="hidden-xs">--%>
<%--                                        <label class="option block mn">--%>
<%--                                            <input type="checkbox" name="mobileos" value="FR">--%>
<%--                                            <span class="checkbox mn"></span>--%>
<%--                                        </label>--%>
<%--                                    </td>--%>
<%--                                    <td>深艾尔</td>--%>
<%--                                    <td>复古</td>--%>
<%--                                    <td>268.0</td>--%>
<%--                                    <td>奶油</td>--%>
<%--                                    <td>1</td>--%>
<%--                                    <td>--%>
<%--                                        <a href="cake_info.html?id=200">查看</a>--%>
<%--                                        <a href="cake_add.html?id=200">编辑</a>--%>
<%--                                        <a href="cake_list.html?id=200">删除</a>--%>
<%--                                    </td>--%>
<%--                                </tr>--%>



                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </section>

</div>
<style>
    /* demo page styles */
    body { min-height: 2300px; }

    .content-header b,
    .admin-form .panel.heading-border:before,
    .admin-form .panel .heading-border:before {
        transition: all 0.7s ease;
    }
    /* responsive demo styles */
    @media (max-width: 800px) {
        .admin-form .panel-body { padding: 18px 12px; }
    }
</style>

<style>
    .ui-datepicker select.ui-datepicker-month,
    .ui-datepicker select.ui-datepicker-year {
        width: 48%;
        margin-top: 0;
        margin-bottom: 0;

        line-height: 25px;
        text-indent: 3px;

        color: #888;
        border-color: #DDD;
        background-color: #FDFDFD;

        -webkit-appearance: none; /*Optionally disable dropdown arrow*/
    }
</style>

<!-- jQuery -->
<script src="/assets/js/jquery-3.3.1.min.js"></script>
<script src="/assets/js/jquery.min.js"></script>
<script src="/assets/js/jquery-ui.min.js"></script>
<!-- Theme Javascript -->
<script src="/assets/js/utility.js"></script>
<script src="/assets/js/demo/demo.js"></script>
<script src="/assets/js/main.js"></script>
<script src="/assets/js/pages.js"></script>
<!-- END: PAGE SCRIPTS -->
</body>

<script type="text/javascript">
    $.ajax({
        async : true,
        url : "/finAll",
        type : "post",
        data : {},
        dataType : "json",
        success : function(data) {
            var arr = data.result;
            console.log(arr);
            $("#type").empty();
            for(var i = 0; i < arr.length; i++) {
                var str = '<tr class="message-unread">';
                str += '<td class="hidden-xs">';
                str += '<label class="option block mn">';
                str += '<input type="checkbox" name="mobileos" value="FR">';
                str += ' <span class="checkbox mn"></span>';
                str += '</label>';
                str += '</td>';
                str += '<td>' + arr[i].title + '</td>';
                str += '<td>' + arr[i].type + '</td>';
                str += '<td>' + arr[i].price + '</td>';
                str += '<td>' + arr[i].taste + '</td>';
                str += '<td>' + arr[i].size + '</td>';
                str += '<td><button>查看</button> ';
                str += '<button>编辑</button> ';
                str += '<button onclick="delcakeid(' + arr[i].id + ')">删除</button>';
                str += '</td>';
                str += '</tr>';
                $("#type").append(str);
            }
        }
    });

    // 删除
    function delcakeid(n) {
        var flag = window.confirm("是否确定删除？");
        if(flag) {
            $.ajax({
                async : true,
                url : "/delcakeid",
                type : "post",
                data : {"id":n},
                dataType : "json",
                success : function(data) {
                    var flag = data.flag;
                    if(flag == 1) {
                        alert("删除成功");
                        window.location.reload();
                    } else {
                        alert("删除失败");
                    }
                }
            });
        }
    }
</script>

</html>
